package com.neusoft.yuejian_01.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;

import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.activity.SearchTrainActivity;
import com.neusoft.yuejian_01.activity.TrainAllActivity;
import com.neusoft.yuejian_01.activity.TrainGActivity;
import com.neusoft.yuejian_01.activity.TrainJActivity;
import com.neusoft.yuejian_01.activity.TrainRActivity;

/**
 * A simple {@link Fragment} subclass.
 */
public class TrainFragment extends Fragment {
    private Button AllButton;//全部培训列表按钮
    private Button TrainRButton;//入门培训列表按钮
    private Button TrainJButton;//进阶培训列表按钮
    private Button TrainGButton;//高级培训列表按钮
    private ImageButton button_search;//搜素培训功能按钮
    private FrameLayout trainALL,trainR,trainJ,trainG;
    public TrainFragment() {
        // Required empty public constructor
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        AllButton = (Button) view.findViewById(R.id.Button_ALL);
        TrainRButton = (Button) view.findViewById(R.id.Button_TrainR);
        TrainJButton = (Button) view.findViewById(R.id.Button_TrainJ);
        TrainGButton = (Button) view.findViewById(R.id.Button_TrainG);
        button_search = (ImageButton) view.findViewById(R.id.button_search);
        trainALL = (FrameLayout) view.findViewById(R.id.trainAll);
        trainR = (FrameLayout) view.findViewById(R.id.trainR);
        trainJ = (FrameLayout) view.findViewById(R.id.trainJ);
        trainG = (FrameLayout) view.findViewById(R.id.trainG);
        initEvents();//点击事件处理
    }
    private void initEvents() {
        button_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), SearchTrainActivity.class);
                startActivity(intent);

            }
        });
        trainALL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TrainAllActivity.class);
                startActivity(intent);

            }
        });
        trainR.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TrainRActivity.class);
                startActivity(intent);
            }
        });
        trainJ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TrainJActivity.class);
                startActivity(intent);
            }
        });
        trainG.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TrainGActivity.class);
                startActivity(intent);
            }
        });
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_train, container, false);
    }

}
